package com.learning.dubbo.base.config.annotation.consumer;

import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.PropertySource;

/**
 * ClassName: Consumer
 * Description: 消费客户端
 * Date: 2020/6/15 13:43 【需求编号】
 *
 * @author Sam Sho
 * @version V1.0.0
 */
@Slf4j
@EnableDubbo(scanBasePackages = "com.learning.dubbo.base.config.annotation.consumer")
@PropertySource("classpath:consumer.properties")
@ComponentScan(value = {"com.learning.dubbo.base.config.annotation.consumer"})
public class Consumer {
    public static void main(String[] args) throws Exception {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Consumer.class);
        context.start();

        // 获取远程服务代理
        BussiService bussiService = context.getBean(BussiService.class);
        // 执行远程方法
        String result = bussiService.doSayHi("Dubbo");
        // 显示调用结果
        log.info(result);
        context.close();
    }
}
